package huajiu.com.serviceImpl;

import huajiu.com.dao.DoctorSolutionDao;
import huajiu.com.dao.ToningSolutionDao;
import huajiu.com.domain.DoctorSolution;
import huajiu.com.domain.ToningSolution;
import huajiu.com.service.ToningSolutionService;
import huajiu.com.vo.DoctorSolutionVo;
import huajiu.com.vo.SolutionVo;

import java.util.List;
import java.util.Random;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ToningSolutionServerImpl implements ToningSolutionService{
	
	@Autowired
	private ToningSolutionDao toningSolutionDao;
	@Autowired
	private DoctorSolutionDao doctorDao;

	@Override
	public void save(ToningSolution toningSolution) {
		toningSolutionDao.save(toningSolution);
	}

	@Override
	public void update(ToningSolution toningSolution) {
		toningSolutionDao.update(toningSolution);		
	}

	@Override
	public void delete(int id) {
		toningSolutionDao.delete(id);
	}

	@Override
	public List<SolutionVo> querySolutionVos() {
		return toningSolutionDao.query();
	}

	@Override
	public SolutionVo query(int id) {
        ToningSolution toningSolution = toningSolutionDao.querySolutionById(id);
        SolutionVo solutionVo =new SolutionVo();
        solutionVo.setPerformance(toningSolution.getPerformance());
        solutionVo.setCorporeity(toningSolution.getCorporeity());
        solutionVo.setTendency(toningSolution.getTendency());
        solutionVo.setToningSolutions(toningSolution.getToningSolutions());
        return solutionVo;
	}

	@Override
	public ToningSolution getCorToningSolution(String corporeity) {
		List<DoctorSolution> doctorSolution = doctorDao.getDoctorSolutions();
		Random random = new Random();
		int randomNum = random.nextInt(doctorSolution.size());
		DoctorSolution doctorSolution2 =(DoctorSolution)doctorSolution.get(randomNum);
		String uuidString = doctorSolution2.getUuid();
		ToningSolution toningSolution = toningSolutionDao.getToningSolution(corporeity,uuidString);
		return toningSolution;
	}

	@Override
	public DoctorSolutionVo getDoctorSolutionVo() {
		// TODO Auto-generated method stub
		return null;
	}

}
